package com.cyclecoder.prototypedemo;

import org.springframework.beans.BeanUtils;
import org.springframework.util.SerializationUtils;

import java.util.List;

/**
 * @author by zhanglei
 * @Date 2021/8/3
 */
public class Test {
    public static void main(String[] args) throws CloneNotSupportedException {
        ProtoTypeTest protoTypeTest = new ProtoTypeTest();
        protoTypeTest.addName();
        ProtoTypeTest p1 = protoTypeTest.clone();
        ProtoTypeTest p2 = protoTypeTest.clone();
        System.out.println(p1);
        System.out.println(p2);
        List<String> list = protoTypeTest.clone().getContents();
        list.add(0, "满江红");
        for (String s : list){
            System.out.println(s);
        }

//        User user = new User();
//        user.setAddress("1");
//        user.setName("2");
//        User user1 = new User();
//        BeanUtils.copyProperties(user1, user);
//        System.out.println(user1.toString());

    }

    public static class User{
        String name;
        String address;

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public String getAddress() {
            return address;
        }

        public void setAddress(String address) {
            this.address = address;
        }

        @Override
        public String toString() {
            return this.address+">>>>"+ this.name;
        }
    }
}
